import {ref, watchEffect} from 'vue'
export default function useStorage(name, value = []) {
  let data = ref(null)
  if (localStorage.getItem(name)) {
    data.value = JSON.parse(localStorage.getItem(name))
  } else {
    data.value = value
  }
  watchEffect(() => {
    const d = data.value
    localStorage.setItem(name, JSON.stringify(d))
    console.log('2222',d)
    console.log('333', JSON.stringify(d))
  })
  return data
}
